//
// Created by wangwanlong on 2024/11/5.
//

#ifndef MKAHYPAR_EDGE_PENALTY_POLICY_H
#define MKAHYPAR_EDGE_PENALTY_POLICY_H

#include "mkahypar/utils/typedef.h"
#include "mkahypar/utils/policy_registry.h"
//blockEdge的超出惩罚策略
namespace mkahypar {
  class NormalEdgePenaltyPolicy : public meta::PolicyBase {
  public:
    //计算超出惩罚
    MKAHYPAR_ATTRIBUTE_ALWAYS_INLINE static inline GainType exceed(HyperedgeWeight fpga_used,
                                                                   HyperedgeWeight fpga_bound) {
      GainType gain = 0;
      if (fpga_used > fpga_bound)
        gain = (fpga_used - fpga_bound) * 10;
      return gain;

    }

    MKAHYPAR_ATTRIBUTE_ALWAYS_INLINE static inline GainType
    computeMove(HyperedgeWeight he_weight, HyperedgeWeight fpga_used,
                HyperedgeWeight fpga_bound) {

      return exceed(fpga_used, fpga_bound) - exceed(fpga_used - he_weight, fpga_bound);
    }

    MKAHYPAR_ATTRIBUTE_ALWAYS_INLINE static inline GainType
    computeAdd(HyperedgeWeight he_weight, HyperedgeWeight fpga_used,
               HyperedgeWeight fpga_bound) {
      return exceed(fpga_used, fpga_bound) - exceed(fpga_used + he_weight, fpga_bound);

    }
    MKAHYPAR_ATTRIBUTE_ALWAYS_INLINE static inline GainType
    computeDelta(HyperedgeWeight old_fpga_used,HyperedgeWeight new_fpga_used,
               HyperedgeWeight fpga_bound) {
      return exceed(old_fpga_used, fpga_bound) - exceed(new_fpga_used, fpga_bound);// >0 正收益

    }
  };
}
#endif //MKAHYPAR_EDGE_PENALTY_POLICY_H
